package com.site.model.backend.system;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

import com.site.util.base.po.BaseApplicationInfo;

/**
 * 资源
 * @author lee 2012-10-12 
 *
 */

@Entity
@Table(name="m_system_resource")
public class ResourseInfo extends BaseApplicationInfo {
	
	private static final long serialVersionUID = 1L;
	

	private Long id;
	/*
	 * 资源名称
	 */
	private String name;
	/*
	 * 菜单标题
	 */
	private String title;
	/*
	 * 菜单访问地址
	 */
	private String url;
	/*
	 * 排序
	 */
	private Integer orderBy;
	/*
	 * 资源子集合
	 */
	private List<ResourseInfo> childrenList;
	/*
	 * 资源父
	 */
	private ResourseInfo parentResourseInfo;

	@Id
	@Column(name = "ID")
	@GeneratedValue(generator = "system-uuid")
	@GenericGenerator(name = "system-uuid", strategy = "increment")
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
	@Column(name="name")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	@Column(name="title")
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}
	@Column(name="url")
	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}
	@Column(name="order_by")
	public Integer getOrderBy() {
		return orderBy;
	}

	public void setOrderBy(Integer orderBy) {
		this.orderBy = orderBy;
	}

	@OneToMany(mappedBy = "parentResourseInfo", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	public List<ResourseInfo> getChildrenList() {
		return childrenList;
	}

	public void setChildrenList(List<ResourseInfo> childrenList) {
		this.childrenList = childrenList;
	}

	public void setParentResourseInfo(ResourseInfo parentResourseInfo) {
		this.parentResourseInfo = parentResourseInfo;
	}
	
	@ManyToOne
	@JoinColumn(name="PID", referencedColumnName = "ID")
	public ResourseInfo getParentResourseInfo() {
		return parentResourseInfo;
	}

}
